<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Transitional//EN" 	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
    //how do I print this thing?
    print '<'
    print '%'
    print '@ taglib prefix="s" uri="/struts-tags" '
    print '%'
    print '>'
%>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<title>${title}</title>
	<script>
        \$(document).ready(function(){
<%
   if (setters) {
      setters.each({
        if (it.name == 'date') {
          def indent = '\t'*3
          println "${indent}\$('#${it.name}').datepicker();"
        }
      })
    }
%>
        });
  </script>
</head>
<body>
    <div class="editModelContainer">
        <s:form method="post" namespace="/${actionName}" action="createOrUpdate">
<%
  def indent = '\t'*3
  import static org.apache.commons.lang.StringUtils.capitalize as capitalize
  if (setters) {
    setters.each({
        switch(it.type) {
            case 'string':
            case 'primitive':
                println "${indent}<s:textfield name='model.${it.name}' label='${capitalize(it.name)}'/>"
                break
            case 'boolean':
                println "${indent}<s:checkbox name='model.${it.name}' label='${capitalize(it.name)}'/>"
                break
            case 'date':
                println "${indent}<s:textfield name='model.${it.name}' label='${capitalize(it.name)}' id='${it.name}'/>"
                break
            default:
                def constraint = constraints.get(it.name)
                if (constraint) {
                    switch(constraint.type) {
                        case 'enum':
                            println "${indent}<s:select name='model.${it.name}' label='${capitalize(it.name)}' id='${it.name}' list='%{@${constraint.enumType}@values()}' listKey='name()' listValue='name()'/>"    
                        break
                    }
                }
        }

    })
    println "${indent}<s:submit />"
  } else {
    println 'Public properties added to the model class will show up here (must have public getter and setter methods) '
  }
%>
        </s:form>
    </div>
</body>
</html>